<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('参数管理')" />
</head>
<body class="gray-bg">
     <div class="container-div">
         <div class="row">
             <div class="col-sm-12 search-collapse">
                 <form id="formId">
                     <div class="select-list" id ='csList'>
                         <ul>
                             <li>
                                 <label>参数类型：</label><!--  含有不同参数类型 -->
                                 <select class="first form-control m-b col-sm-3"  id="paramterId" name="paramterId"></select>
                             </li>
                             <li>
                                 <label>备注：</label><!--  含有不同参数类型 -->
                                 <input class="first form-control m-b col-sm-3" id="bak" name="bak"></input>
                             </li>
                             <li>
                                 <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                 <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                             </li>
                         </ul>
                     </div>
                 </form>
             </div>

             <div class="btn-group-sm" id="toolbar" role="group">
                 <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="sujian:parameterManagement:add">
                     <i class="fa fa-plus"></i> 添加
                 </a>
                 <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="sujian:parameterManagement:edit">
                     <i class="fa fa-edit"></i> 修改
                 </a>
                 <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="sujian:parameterManagement:remove">
                     <i class="fa fa-remove"></i> 删除
                 </a>
                 <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="sujian:parameterManagement:export">
                     <i class="fa fa-download"></i> 导出
                 </a>
                 <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="sujian:parameterManagement:import">
                     <i class="fa fa-upload"></i> 导入
                 </a>
                 <a class="btn btn-info" onclick="calculate()" shiro:hasPermission="sujian:parameterManagement:calculateValue">
                     <i class="fa fa-adn"></i> 计算
                 </a>
             </div>
             <div class="col-sm-12 select-table table-striped">
                 <table id="bootstrap-table"></table>
             </div>
         </div>
    </div>
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: jquery-cxselect-js" />
    <script th:inline="javascript">
        var data = [[${data}]];
        $('#csList').cxSelect({
            selects: ['first'],
            required: true,
            jsonValue: 'v',
            data: data
        });
        var options;
        var prefix = ctx + "sujian/parameterManagement";
        function query(){
            if(options!=null&&options!=undefined){
                var params = $("#bootstrap-table").bootstrapTable('getOptions');
                $("#bootstrap-table").bootstrapTable('refresh', params);
            }else{
                options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    removeUrl: prefix + "/remove",
                    updateUrl: prefix + "/edit/{id}",
                    importUrl: prefix + "/importData",
                    exportUrl: prefix + "/export",
                    importTemplateUrl: prefix + "/importTemplate",
                    // calculateUrl: prefix + "/calculateValue",
                    uniqueId:"paramterUUID",
                    sortName: "updatetime",
                    sortOrder: "desc",
                    modalName: "参数管理",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'paramterUUID',
                            title: '参数类型UUID',
                            visible: false
                        },
                        {
                            field: 'paramterId',
                            title: '参数类型ID',
                            visible: false
                        },
                        {
                            field: 'paramterName',
                            title: '参数类型名称'
                        },
                        {
                            field: 'paramterLlId',
                            title: '参数类型1',
                            visible: false
                        },
                        {
                            field: 'paramterLlName',
                            title: '参数类型1名称'
                        },
                        {
                            field: 'paramterLl2Id',
                            title: '参数类型2',
                            visible: false
                        },
                        {
                            field: 'paramterLl2Name',
                            title: '参数类型2名称'
                        },
                        {
                            field: 'paramterValue',
                            title: '参数值'
                        },
                        {
                            field: 'bak',
                            title: '备注'
                        },
                        {
                            field: 'cratetime',
                            title: '创建时间',
                            sortable: true
                        },
                        {
                            field: 'updatetime',
                            title: '更新时间'
                        }]
                };
                $.table.init(options);
            }
        }
    function calculate(){
            table.set();
            var url =  prefix + "/calculateValue";
            var data = { };
            $.operate.submit(url, "post", "json", data);
        }
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果参数已经存在，更新这条数据。"> 是否更新已经存在的参数数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs" shiro:hasPermission="sujian:parameterManagement:template"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>